<style>
	.file_download {
		text-align: center;
		position: relative;
	}
	
	.file_download p {
		color: #FFF;
		position: absolute;
		top: 35px;
		left: 55px;
	}
	
	.btn_margin {
		margin-top: 20px;
	}
	
	.picter img {
		width: 80px;
		height: 80px;
	}
	
	.model_pic img {
		width: 100%;
		height: auto;
	}
</style>
<include file="Public/min-header" />
<div class="wrapper">
	<include file="Public/breadcrumb" />
	<section class="content">
		<div class="row">
			<div class="col-xs-12">
				<div class="box">
					<nav class="navbar navbar-default">
						<div class="collapse navbar-collapse">
							<div class="navbar-form pull-right margin">
								<if condition="$order['order_status'] lt 2">
									<a href="{:U('Admin/order/edit_order',array('order_id'=>$order['order_id']))}" data-toggle="tooltip" title="" class="btn btn-primary" data-original-title="编辑">修改订单</a>
								</if>
								<if condition="($split eq 1) and ($order['order_status'] lt 2)">
									<a href="{:U('Admin/order/split_order',array('order_id'=>$order['order_id']))}" data-toggle="tooltip" title="" class="btn btn-primary" data-original-title="编辑">拆分订单</a>
								</if>
								<a href="{:U('Order/order_print',array('order_id'=>$order['order_id']))}" target="_blank" data-toggle="tooltip" title="" class="btn btn-primary" data-original-title="打印订单">
									<i class="fa fa-print"></i>打印订单
								</a>
								<a href="javascript:history.go(-1)" data-toggle="tooltip" title="" class="btn btn-default" data-original-title="返回"><i class="fa fa-reply"></i></a>
							</div>
						</div>
					</nav>
 <if condition="$admin_id eq '1' "> 
					<!--新订单列表 基本信息-->
					<div class="panel panel-default">
						<div class="panel-heading">
							<h3 class="panel-title text-center">基本信息</h3>
						</div>
						<div class="panel-body">
							<table class="table table-bordered">
								<tbody>
									<tr>

										<td>图号 ID:</td>
										<td>订单号:</td>
										<td>图号:</td>
										<td>会员:</td>
										<td>电话:</td>
										<td>加工类型:</td>
										<td>产品名称:</td>
										<td>产品备注:</td>
										<td>产品数量:</td>
										<td>交货时间:</td>
										<td>下单时间:</td>
									</tr>
									<tr>
										<foreach name="order" item="value">

											<td>{$value.id}</td>
											<td id="order_sn">{$value.order_sn}</td>
											<td id="order_chartNumber">{$value.chart_number}</td>
											<td>{$value.user_name}</td>
											<td>{$value.mobile}</td>
											<td style="color: #00A65A;">{$value.type}</td>
											<td>{$value.name}</td>
											<td>{$value.remark}</td>
											<td>{$value.product_quantity}</td>
											<td style="color: #3C8DBC;">{$value.time_delivery}</td>
											<td>{$value.dates}</td>
										</foreach>
									</tr>

								</tbody>
							</table>

						</div>
					</div>
</if>
					<!--客户上传文件处理-->
					<div class="panel panel-default">
						<div class="panel-heading">
							<h3 class="panel-title text-center">客户上传的文件</h3>
						</div>
						<div class="panel-body">
							<div class="row">
								<foreach name="wenjian" item="value">
									<foreach name="value" item="v">
										<div class="col-xs-2">
											<div class="file_download">
												<img src="/public/images/file_download.png" />
												<p>{$key}</p>
											</div>
											<div class="text-center btn_margin">
												<!--<p>title.jpg</p>-->
												<a class='btn btn-success btn-sm' href="{$v}">下载文件</a>
											</div>
										</div>
									</foreach>
								</foreach>
								<foreach name="tupian" item="value">
									<div class="col-xs-2">

										<div class="picter text-center">
											<!--如果是 jpg png 就用自己-->
											<img src="{$value}" />
										</div>
										<div class="text-center btn_margin">
											<a class="btn btn-primary btn-sm toNewPage" data-url="{$value}" id="toNewPage">预览图片</a>
											<!--  图片不需要下载 -->
											<!--<button class="btn btn-primary btn-sm" data-toggle="modal" data-target="#index{$key}">预览图片</button>               		-->
										</div>
									</div>

								</foreach>

							</div>
						</div>
					</div>
					<if condition="$order[0][allot_status] neq 0">
						<div class="panel panel-default">
							<div class="panel-heading">
								<h3 class="panel-title text-center">分配工序</h3>
								<!--<button class="btn btn-primary pull-right" style="position: relative;bottom: 25px;">修改分配工序</button>-->
								<if condition="$admin_id eq '1' and $order[0]['jiaqian'] eq '0' ">
									<a href="{:U('Admin/order/edit_fpgx',array('order_id'=>$order[0]['chart_number'],'order_sn'=>$order[0]['order_sn']))}" data-toggle="tooltip" title="" class="btn btn-primary pull-right" style="position: relative;bottom: 25px;">修改分配工序</a>
								</if>
							</div>
							<div class="panel-body">
								<table class="table table-bordered">
									<tbody>
										<tr>

											<td>工序</td>
											<td>工序名称</td>

										</tr>
										<foreach name="fpgx" item="value">

											<tr>

												<td>工序{$key +1}</td>
												<td>{$value.name}</td>
											</tr>
										</foreach>
									</tbody>
								</table>
							</div>
						</div>

					</if>

					<!--工序报价-->
					<div class="panel panel-default">
						<div class="panel-heading">
							<h3 class="panel-title text-center">工序报价</h3>
							<if condition="$order[0]['jiaqian'] eq '0' ">
								<a href="{:U('Admin/order/edit_gxbj',array('order_id'=>$order[0]['chart_number'],'order_sn'=>$order[0]['order_sn']))}" data-toggle="tooltip" title="" class="btn btn-primary pull-right" style="position: relative;bottom: 25px;">修改工序报价</a>
							</if>
						</div>
						<div class="panel-body">
							<table class="table table-bordered">
								<tbody>
									<tr>

										<td>工序</td>
										<td>公司名称</td>
										<td>报价</td>

									</tr>
									<foreach name="baojia" item="value">
										<tr>

											<td class="get_number">工序{$value.id}</td>
											<td>{$value.qiyename}</td>
											<td>{$value.jiaqian}</td>
										</tr>
									</foreach>
								</tbody>
							</table>
						</div>
					</div>
					<if condition="$admin_id eq '1' ">
						<!--审核-->
						<div class="panel panel-default">
							<div class="panel-heading">
								<h3 class="panel-title text-center">报价审核</h3>
							</div>
							<div class="panel-body text-center">
								<if condition="$order[0]['allot_status'] eq '2' and $order[0]['audit'] eq '0' ">
									<button onclick="examine()" class="btn btn-success">通过审核</button>
									<elseif condition="$order[0]['audit'] eq '1' "/>
									<h1/>已经通过审核
									<h1/>
								</if>
								<if condition="$order[0]['allot_status'] eq '1' ">
									<h1/>等待工序全部报价
									<h1/>
								</if>
								
							</div>
						</div>
					</if>
				</div>
			</div>
		</div>
	</section>
</div>

<!-- 预览图片模态框 -->
<foreach name="tupian" item="value">

	<div class="modal fade" id="index{$key}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
		<div class="modal-dialog" role="document">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
					<h4 class="modal-title" id="myModalLabel"></h4>
				</div>
				<div class="modal-body model_pic">
					<!--这是预览图片 -->
					<img src="{$value}" />
				</div>
			</div>
		</div>
	</div>
</foreach>
</section>
</div>

<!--成功提示框-->
<div class="modal fade bs-example-modal-sm" id="myModal_success" tabindex="-1">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-body">
				<h4 class="text-center">操作成功</h4>
			</div>
			<div class="modal-footer">

				<a href="/index.php/Admin/Order/skip/order_sn/{$order[0]['order_sn']}" type="button" class="btn btn-success btn-block">确认</a>
				<!-- <a href="http://www.jiejiangpt.com/index.php/Admin/Order/skip" type="button" class="btn btn-success btn-block" >确认</a>-->

			</div>
		</div>
	</div>
</div>

</body>
<script>
	$('.toNewPage').on('click',function(){
		var url = $(this)[0].dataset.url;
		window.open(url);
	})
	$(function() {
		var arr = [];
		$('.get_number').each(function() {
			var old = parseInt($(this).text().substr(2));
			arr.push(old);
		})

		var first_childer = arr[0];
		for(var i = 0; i < arr.length; i++) {
			arr[i] = arr[i] - first_childer + 1;
		}
		console.log(arr);

		$('.get_number').each(function(i) {
			$(this).html('工序' + arr[i]);
		})

	})

	function pay_cancel(obj) {
		var url = $(obj).attr('data-url') + '/' + Math.random();
		layer.open({
			type: 2,
			title: '退款操作',
			shadeClose: true,
			shade: 0.8,
			area: ['45%', '50%'],
			content: url,
		});
	}
	//取消付款
	function pay_callback(s) {
		if(s == 1) {
			layer.msg('操作成功', {
				icon: 1
			});
			layer.closeAll('iframe');
			location.href = location.href;
		} else {
			layer.msg('操作失败', {
				icon: 3
			});
			layer.closeAll('iframe');
			location.href = location.href;
		}
	}

	// 弹出退换货商品
	function selectGoods2(order_id) {
		var url = "/index.php?m=Admin&c=Order&a=get_order_goods&order_id=" + order_id;
		layer.open({
			type: 2,
			title: '选择商品',
			shadeClose: true,
			shade: 0.8,
			area: ['60%', '60%'],
			content: url,
		});
	}
	// 申请退换货
	function call_back(order_id, goods_id) {
		var url = "/index.php?m=Admin&c=Order&a=add_return_goods&order_id=" + order_id + "&goods_id=" + goods_id;
		location.href = url;
	}

	function examine() {
		var order_sn = $('#order_sn').text();
		var order_chartNumber = $('#order_chartNumber').text();

		$.ajax({
			type: "post",
			url: "http://www.jiejiangpt.com/index.php/Admin/order/audit",
			data: {
				'order_sn': order_sn,
				'order_chartNumber': order_chartNumber
			},
			success: function(data) {
				//			
				if(data == 1) {
					$('#myModal_success').modal('show');
				}
			},
			async: true
		});

	}
</script>

</html>